<?php $this->_extends('../_layouts/default_layout'); ?>
<?php $this->_block('contents'); ?>
<script type="text/javascript">
$(function(){
	$(".img").colorbox();
	$(".message_template").change(function(){
		$.ajax({
			type: "GET",
			url: "<?=url('Services::EbayMessage/MessageTemplateAjax')?>&id=" + $(this).val(),
			dataType: "text",
			success:
				function(data)
				{
					$("#body").val(data);
				}
		});
	});
	var i = 1;
	$(".add_file_input").click(function(){
		if (i <= 5)
		{
			$("#file_input").append('<input type="file" name="picture' + i + '" style="width: 200px;" />');
			i++;
		}
		else
		{
			alert('添加图片不能超过五个！');
			return false;
		}
	});
	$(".send_message_btn").click(function(){
		$(this).attr('disabled', true);
		$(this).next().show();
		$("#contact_member_form").submit();
	});
});
</script>
<table width="60%">
<tr>
	<td width="100px"><a class="img" href="<?=$listing['gallery_picture_url']?>"><img width="100px" height="100px" src="<?=$listing['gallery_picture_url']?>" /></a></td>
	<td valign="top">
		<p>Title：<?=$listing['title']?></p>
		<p>ItemID：<?=$listing['item_id']?></p>
		<p>上架时间：<?=$listing['start_time']?></p>
		<p>结束时间：<?=$listing['end_time']?></p>
	</td>
</tr>
</table>
<form action="<?=url('Services::EbayMessage/contactMemberSave')?>"  method="post"  id="contact_member_form" enctype="Multipart/form-data">
<input type="hidden" name="listing_id" value="<?=$listing['id']?>" />
<input type="hidden" name="user" value="<?=$user?>" />
<table width="60%">
<tr>
	<td align="right" width="60px" height="25px">To：</td>
	<td><strong><?=$user?></strong></td>
</tr>
<tr>
	<td align="right" height="25px">回复模板：</td>
	<td>
		<select class="message_template">
			<option value="0">--请选择--</option>
			<?foreach ($message_template as $mt):?>
			<option value="<?=$mt['id']?>"><?=$mt['name']?></option>
			<?endforeach;?>
		</select>
		<a class="add_file_input" style="margin-left: 100px;">添加图片</a>
	</td>
</tr>
<tr>
	<td></td>
	<td id="file_input"></td>
</tr>
<tr>
	<td align="right">Body：</td>
	<td>
		<textarea rows="10" cols="96%" name="body" id="body"></textarea>
	</td>
</tr>
<tr>
	<td align="right" height="25px">From：</td>
	<td><strong><?=$listing['shop_name']?></strong></td>
</tr>
<tr>
	<td><input type="hidden" name="<?=Q::ini('unique_token_name')?>" value="<?=Helper_BSS_Normal::genToken()?>" /></td>
	<td>
		<input type="button" class="button send_message_btn" value="发送邮件" />
		<img src="<?=Q::ini('custom_system/base_url')?>img/loading.gif" style="display: none" />
	</td>
</tr>
</table>
</form>
<?php $this->_endblock(); ?>